package com.woniuxy.microcontentserver.advertisemsg.service.impl;

import com.woniuxy.microcontentserver.advertisemsg.mapper.AdvertiseMapper;
import com.woniuxy.microcontentserver.advertisemsg.service.IAdvertiseService;
import com.woniuxy.microcontentserver.bean.AdvertiseBean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Transactional(readOnly = true)
@Service
public class AdvertiseServiceImpl implements IAdvertiseService {
    @Resource
    private AdvertiseMapper advertiseMapper;

    /**
     * 查询所有广告
     * @param advertiseBean
     * @return
     */
    @Override
    public List<AdvertiseBean> findAll(AdvertiseBean advertiseBean) {
        return advertiseMapper.findAll(advertiseBean);
    }

    @Override
    public AdvertiseBean getOneById(Long id) {
        return advertiseMapper.getOneById(id);
    }

    @Override
    public List<AdvertiseBean> findByCondition(AdvertiseBean advertiseBean) {
        return advertiseMapper.findByCondition(advertiseBean);
    }

    /**
     * 添加广告
     * @param advertiseBean
     * @return
     */
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor =Exception.class)
    @Override
    public int addAdvertiseBean(AdvertiseBean advertiseBean) {
        return advertiseMapper.addAdvertiseBean(advertiseBean);
    }

    /**
     * 修改广告
     * @param advertiseBean
     * @return
     */
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor =Exception.class)
    @Override
    public int updateAdvertiseBean(AdvertiseBean advertiseBean) {
        return advertiseMapper.updateAdvertiseBean(advertiseBean);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor =Exception.class)
    @Override
    public int deleteAdvertiseBean(Long id) {
        return advertiseMapper.deleteAdvertiseBean(id);
    }


}
